package com.lyt.controller;

import com.lyt.bean.Result;
import com.lyt.bean.User;
import com.lyt.dao.UserDao;
import com.lyt.util.AesUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * @Author: lyt
 * @Date: 2023/04/09/20:03
 *
 * @Description:
 *
 */
@RestController
public class LoginController {
    @Autowired
    UserDao userDao;


    @CrossOrigin
    @RequestMapping("/login")
    public String userLogin(@RequestBody User user) {
//        System.out.println("User : " + user);
//        String passWord= AesUtil.decrypt(user.getPassword(),"XXXXXXXXXXXXXX");
//        System.out.println("解密后的密码"+passWord);
//        String str = "error";
//        int count = userDao.getUserByMassage(user.getUsername(), user.getPassword());
//        if (count > 0) {
//            str = "ok";
//        }
        return null;
    }


    @CrossOrigin
    @RequestMapping("/stress")
    public Result stressTest() {
        System.out.println("来自压力测试的请求");




        return new Result("200","测试成功");
    }



    @RequestMapping("/loginTest")
    public String userLoginTest(@RequestBody User user) {
        System.out.println("User : " + user);


        String str = "error";

//        int count = userDao.getUserByMassage(user.getUsername(), user.getPassword());
       int count = 0;
        if (count > 0) {
            str = "ok";
        }
        return str;
    }
}
